<template>
  <div>
    <el-form ref="form" :model="form" label-width="100px">
      <el-form-item label="商品编号">
        <el-input v-model="form.proID"></el-input>
      </el-form-item>
      <el-form-item label="商品名称">
        <el-input v-model="form.proName"></el-input>
      </el-form-item>
      <el-form-item label="供应商">
        <el-input v-model="form.supplier"></el-input> </el-form-item
      ><el-form-item label="进价">
        <el-input v-model="form.inPrice"></el-input> </el-form-item
      ><el-form-item label="售价">
        <el-input v-model="form.outPrice"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认</el-button>
        <el-button @click="reset">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import axios from 'axios'
import qs from 'qs'
export default {
  data() {
    return {
      form: {
        proID: "",
        proName:"",
        supplier: "",
        inPrice: "",
        outPrice: ""
      },
      money: 3000,
    };
  },
  methods: {
    onSubmit() {
     axios({
       url:'http://localhost:3000/addProduct',
       method:'post',
       data:qs.stringify({
       proID:this.form.proID,
       proName:this.form.proName,
       supplier:this.form.supplier,
       inPrice:this.form.inPrice,
       outPrice:this.form.outPrice
       })
     })
     this.$message({
          message: '添加成功！',
          type: 'success'
        });
      history.back()
    },
    reset(){
      this.$router.push('/product')
    }
  }
};
</script>

<style scoped>
</style>